home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / findhit4.lha / FindHit.doc < prev    next >
Encoding:
Text File  |  1993-07-01  |  8.1 KB  |  221 lines

  1.  
  2.                             FindHit 37.4
  3.  
  4.                                   by
  5.                             Douglas Keller
  6.  
  7.                    Copyright 1993 by Douglas Keller
  8.  
  9.                             July 1, 1993
  10.  
  11.  
  12. 0. Introduction
  13. ---------------
  14.  
  15. FindHit is used to find the line numbers where Enforcer and Mungwall
  16. hits occur in C source code.  The idea for FindHit came from Doug
  17. Walker's Hitme program.
  18.  
  19. FindHit requires AmigaDOS 2.0, v37 or greater.
  20.  
  21.  
  22. 1. Contents
  23. -----------
  24.  
  25. FindHit     - FindHit v37.4.
  26. FindHit.doc - This doc file.
  27.  
  28. FindHit.c   - Sas/C 6.3 source for FindHit.
  29. headers.h   - System headers included by FindHit.c.
  30. lmkfile     - Sas/C 6.3 smake makefile.
  31.  
  32. offender     - Example program that cause Enforcer and Mungwall hits.
  33. offender.c   - Sas/C 6.3 source for offender.
  34. offender.map - Mapfile for offender produced by slink.
  35.  
  36.  
  37. 2. How to use FindHit
  38. ---------------------
  39.  
  40. FindHit takes the following command line arguments:
  41.  
  42.   MAPFILE/A,OFFSET/A/M,HUNK/N,DEL=DELETEOMDFILE/S
  43.  
  44.     MAPFILE/A  - Name of the mapfile from Slink, for the program
  45.                  that produced the hit.  The mapfile is the file Slink
  46.                  generates when the MAP <map_file_name>,h option is used.
  47.                  This argument is required.
  48.  
  49.     OFFSET/A/M - Offset that Enforcer or Mungwall reports that
  50.                  caused the hit.  This value is in hexadecimal
  51.                  with no leading $ or 0x.  Multiple offsets can
  52.                  be specified, but at least on offset is required.
  53.  
  54.     HUNK/N     - The hunk that Enforcer or Mungwall reports that
  55.                  caused the hit.  The hunk is not required and if
  56.                  it is no specified the default hunk will be zero.
  57.  
  58.     DEL=DELETEOMDFILE/S - This tells FindHit to delete the Omd file
  59.                  after it is done.  By default the Omd file is NOT
  60.                  deleted.  If FindHit is run and it finds an Omd file
  61.                  that is not out of date it will use the Omd file
  62.                  without running Omd again.  The Omd file is generated
  63.                  in t:.
  64.  
  65. Here are some examples of running FindHit:
  66.  
  67.   1> findhit offender.map 270
  68.  
  69.      Found offset 0x00000270 in "offender.c", on line 11
  70.  
  71.      Searchs offender.map for offset 270 hex in hunk 0.  The output
  72.      shows the hit was found on line 11 of offender.c.
  73.  
  74.   1> findhit rush.map 1ac44 hunk 2 delomdfile
  75.  
  76.      Found offset 0x0001AC44 in "req_palette.c", on line 278
  77.  
  78.      Searchs rush.map for offset 1ac44 hex in hunk 2, and deletes
  79.      the omd file after it is done.
  80.  
  81.   1> findhit magic.map 988 4ac8 857c
  82.  
  83.      Found offset 0x00000988 in "magic.c", on line 173
  84.      Found offset 0x00004AC8 in "addgads.c", on line 470
  85.      Found offset 0x0000857C in "cmds2.c", on line 310
  86.  
  87.      Searchs magic.map for the three offsets 988, 4ac8, and 857c.
  88.  
  89. If some of the filenames of your object files are longer then 15
  90. characters make sure you use the FWIDTH option in Slink to increase
  91. the length of the filename field of the mapfile.  FindHit will
  92. automatically find the correct information even if the mapfile width's
  93. change.
  94.  
  95.  
  96. 3. Using FindHit with Enforcer, Mungwall, and SegTracker
  97. --------------------------------------------------------
  98.  
  99. For best results you should be using the latest versions of Enforcer
  100. and Mungwall which take advantage of SegTracker.
  101.  
  102. When the included offender program is run it produces the following
  103. hits.
  104.  
  105.   BYTE-WRITE to  00000000        data=61         PC: 07A11A4A
  106.   USP:  07A0ABFC SR: 0000 SW: 0711  (U0)(-)(-)  TCB: 07B82A88
  107.   Data: 07A0ABFC 00000002 000003ED 00000FA8 00000001 0000002B 0000003B 07B82AE4
  108.   Addr: 079FEC2A 079E9020 079F64F9 079F64FC 079FE9E8 00000000 0780DF24 --------
  109.   ----> 079FEC2A - "offender"  Hunk 0001 Offset 00000242
  110.   ----> 079FE9E8 - "offender"  Hunk 0001 Offset 00000000
  111.   Stck: 079FEC2E 0780DF24 07A1236A 00000001 079FEC2A 07A12042 0000FFFF 07B83B24
  112.   Stck: 07B82A88 00F95106 07800810 00000000 07A0AC3C 00008011 01EE10FB 00000000
  113.   ----> 07A11A4A - "offender"  Hunk 0000 Offset 0000028A
  114.   ----> 079FEC2E - "offender"  Hunk 0001 Offset 00000246
  115.   ----> 07A1236A - "offender"  Hunk 0000 Offset 00000BAA
  116.   ----> 079FEC2A - "offender"  Hunk 0001 Offset 00000242
  117.   ----> 07A12042 - "offender"  Hunk 0000 Offset 00000882
  118.   Name: "New_WShell"  CLI: "offender"  Hunk 0000 Offset 0000028A
  119.    
  120.   BYTE-WRITE to  00000000        data=62         PC: 07A11A30
  121.   USP:  07A0ABF4 SR: 0000 SW: 0711  (U0)(-)(-)  TCB: 07B82A88
  122.   Data: 07A0ABFC 00000002 000003ED 00000FA8 00000001 0000002B 0000003B 07B82AE4
  123.   Addr: 079FEC2A 079E9020 079F64F9 079F64FC 079FE9E8 00000000 0780DF24 --------
  124.   ----> 079FEC2A - "offender"  Hunk 0001 Offset 00000242
  125.   ----> 079FE9E8 - "offender"  Hunk 0001 Offset 00000000
  126.   Stck: 00000000 07A11A4C 079FEC2E 0780DF24 07A1236A 00000001 079FEC2A 07A12042
  127.   Stck: 0000FFFF 07B83B24 07B82A88 00F95106 07800810 00000000 07A0AC3C 00008011
  128.   ----> 07A11A30 - "offender"  Hunk 0000 Offset 00000270
  129.   ----> 07A11A4C - "offender"  Hunk 0000 Offset 0000028C
  130.   ----> 079FEC2E - "offender"  Hunk 0001 Offset 00000246
  131.   ----> 07A1236A - "offender"  Hunk 0000 Offset 00000BAA
  132.   ----> 079FEC2A - "offender"  Hunk 0001 Offset 00000242
  133.   ----> 07A12042 - "offender"  Hunk 0000 Offset 00000882
  134.   Name: "New_WShell"  CLI: "offender"  Hunk 0000 Offset 00000270
  135.  
  136.   Mismatched FreeMem size 99!
  137.   Original allocation: 100 bytes from A:0x7A11A58 C:0x780DF24 Task 0x7B82A88
  138.   Testing with original size.
  139.    
  140.     FreeMem(0x79FE018,99) attempted by "offender" (TCB:07B82A88)
  141.     from A:0x7A11A62 C:0x780DF24 SP:0x7A0ABF8
  142.   APC:0x07A11A62 in seglist of "offender"   Hunk 0000 Offset 000002A2
  143.  
  144.  
  145. The first hit is in hunk 0 at offset 28A, if the follow is typed:
  146.  
  147.     1> findhit offender.map 28a
  148.  
  149.        Found offset 0x0000028A in "offender.c", on line 20
  150.  
  151. This shows the hit is in offender.c on line 20.
  152.  
  153. The second hit is a little more interesting, it is in a
  154. subroutine.  The second ----> line, which is from SegTracker, that
  155. Enforcer reports is:
  156.  
  157.     ----> 07D20D9C - "offender"  Hunk 0000 Offset 0000028C
  158.  
  159. This is the offset in offender where the function that caused the hit
  160. is called from.  This SegTracker information can be helpful if
  161. Enforcer does not find the Name of the program that caused the hit.
  162.  
  163. The last hit is from Mungwall, it shows the FreeMem() that has the
  164. problem is in hunk 0 offset 2a2.
  165.  
  166. If some of the filenames of your object files are longer then 15
  167. characters make sure you use the FWIDTH option in Slink to increase
  168. the length of the filename field of the mapfile.  FindHit will
  169. automatically find the correct information even if the mapfile width's
  170. change.
  171.  
  172.  
  173. 4. How FindHit Works
  174. --------------------
  175.  
  176. FindHit search through the mapfile that Slink generates to find the
  177. object file that has the problem.  FindHit then executes Omd on the C
  178. source and the object file to disassemble it.  The base of the object
  179. file, from the mapfile, plus the offset into the Omd file should equal
  180. the offset that Enforcer or Mungwall reports.
  181.  
  182. Since Omd is used to disassemble the code, code must be compiled with
  183. a debug level of at least DEBUG=LINE.
  184.  
  185. If the DELETEOMDFILE option is not given the Omd file is generated in
  186. T: and is not deleted ater FindHit is done with it.  The next time
  187. FindHit is run it checks the date of the Omd file and the object file
  188. to see of the Omd file needs to be regenerated.  If the Omd file is
  189. newer then the object file, FindHit uses the Omd file that it finds in
  190. T:, else it generates the Omd file again.
  191.  
  192. If you prefer the default to delete the Omd file, the following alias
  193. can be made:  alias FindHit "FindHit deleteomdfile".
  194.  
  195.  
  196. 5. About the Source
  197. -------------------
  198.  
  199. Sas/C 6.3 source is included.  The source does not use any startup
  200. code and there is not writable global data, so it is reentrant.
  201.  
  202.  
  203. 6. Legal junk
  204. -------------
  205.  
  206. Permission is granted to distribute this program and its documentation
  207. for non-commercial purposes as long as the copyright notices are not
  208. removed.  This program may not be distributed for a profit without
  209. permission from Doug Keller.  Fred Fish has permission to distribute
  210. this program as part of the Fred Fish library.
  211.  
  212.  
  213. 7. Bugs and Info
  214. ----------------
  215.  
  216. If you would like to get in touch with me I can be reached on the
  217. following:
  218.  
  219.             Bix : dkeller
  220.         Internet: dkeller@vnet.ibm.com
  221.